class UserInfo:
    def __init__(self, email, name, password, qq):
        self.email = email
        self.name = name
        self.password = password
        self.qq = qq

    def __str__(self):
        return '邮箱是：{}，名字是：{}密码是：{}，QQ 是：{}。'.format(self.email, self.name, self.password, self.qq)


def open_txt(filename):
    txt = open(filename, 'r')
    context = txt.read()
    return context


def txt_to_dict(txt):
    return eval(txt)


def save_users(users):
    for i in range(len(users)):
        p = UserInfo(users[i]['email'], users[i]['name'], users[i]['password'], users[i]['qq'])
        print(p)


def main():
    user_dict = txt_to_dict(open_txt('json.txt'))
    print(user_dict[2]['name'])
    save_users(user_dict)


main()
